<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\Resource;

class ArchiveReportResource extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        /** @var \App\Models\Archive $report */
        $report = $this;

        foreach ($photos as $key => $photo) {
            $photos[$key] = asset($photo);
        }
        return [
            'ReportID' => $report->record_no,
            'ReportVideo' => asset($report->video),
            'Phone' => $report->phone,
            'ReturnVisitFlag' => 1,
            'Region' => "3",
            'CoordinateY' => $report->latitude,
            'CoordinateX' => $report->longitude,
            'Address' => $report->address,
            'EventDesc' => $report->message,
            'ReportAudio' => asset($report->audio),
            'ReplyTypeID' => 2,
            'ReportTime' => $report->created_at->toDateTimeString(),
            'QuestionID' => $report->record_no,
            'ReportName' => $report->user->username,
            'QuestionNames' => $report->record_username,
            'ReportImg' => implode(',', $photos),
            'Email' => ''
        ];
    }
}
